/*
 * @Author: your name
 * @Date: 2021-04-09 13:56:43
 * @LastEditTime: 2021-05-13 10:37:50
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /vite-project/src/utils/http/types.ts
 */

import { AxiosRequestConfig } from 'axios';
import { AxiosTransform } from './axiosTransform';

export interface CreateAxiosOptions extends AxiosRequestConfig {
    prefixUrl?: string;
    transform?: AxiosTransform;
    requestOptions?: RequestOptions;
}

export interface RequestOptions {
    //请求参数拼接到url
    joinParamsToUrl?: boolean;
    //格式化请求参数时间
    formatDate?: boolean;
    //是否处理请求结果
    isTransformRequestResult?: boolean;
    //是否显示提示信息
    isShowMessage?: boolean;
    //是否解析成JSON
    isParseToJson?: boolean;
    //是否显示成功信息
    isShowSuccessMessage?: boolean;
    //是否显示失败信息
    isShowErrorMessage?: boolean;
    //是否加入url
    joinPrefix?: boolean;
    //接口地址，
    apiUrl?: string;
    // Whether to add a timestamp
    joinTime?: boolean;
}

export interface Result<T = any> {
    code: number;
    type: 'success' | 'error' | 'warning';
    message: string;
    result?: T;
    token: string;
}
